﻿
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "IObject.h"

#include "UIComponent.h"

namespace gcmp
{
    class IParameterValueDisplayString;
    class UniIdentity;
    class IParameterValueList;
}

namespace Sample
{
    /// \brief 内建参数显示属性值构造器
    ///
    /// 用于指定内建参数的显示属性值
    class UICOMPONENT_EXPORT IBuiltInParameterDisplayCreator : public gcmp::IObject
    {
        DEFINE_CAST_DERIVED(IBuiltInParameterDisplayCreator, gcmp::IObject)
    public:
        /// \brief 添加静态下拉列表的属性值
        /// 
        /// \param uniIdentity 参数的UniIdentity
        /// \return 内建参数显示属性值构造器指针
        static gcmp::OwnerPtr<IBuiltInParameterDisplayCreator> AddStacticDropdownListParameterDisplay(const gcmp::UniIdentity& uniIdentity, const std::vector<gcmp::OwnerPtr<gcmp::IParameterValueDisplayString>>& parameterValueDisplayStrings);

        /// \brief 添加动态下拉列表的属性值
        /// 
        /// \param oValueList 动态下拉列表要显示的属性值
        /// \see IParameterValueList
        /// \return 内建参数显示属性值构造器指针
        static gcmp::OwnerPtr<IBuiltInParameterDisplayCreator> AddDynamicDropdownListParameterDisplay(gcmp::OwnerPtr<gcmp::IParameterValueList> oValueList);

        /// \brief 添加带扩展项动态下拉列表的属性值
        /// 
        /// \param oValueList 动态下拉列表要显示的属性值
        /// \param externalItemDiaplayString 扩展项显示字符串
        /// \see IParameterValueList
        /// \return 内建参数显示属性值构造器指针
        static gcmp::OwnerPtr<IBuiltInParameterDisplayCreator> AddDynamicDropdownListWithExternalItemParameterDisplay(gcmp::OwnerPtr<gcmp::IParameterValueList> oValueList, std::wstring externalItemDiaplayString = L"");

        /// \brief 替换动态下拉列表的属性值
        /// 
        /// \param oValueList 动态下拉列表要显示的属性值
        /// \see IParameterValueList
        /// \return 内建参数显示属性值构造器指针
        static gcmp::OwnerPtr<IBuiltInParameterDisplayCreator> ReplaceDynamicDropdownListParameterDisplay(gcmp::OwnerPtr<gcmp::IParameterValueList> oValueList);
    };

    typedef std::vector<gcmp::OwnerPtr<gcmp::IParameterValueDisplayString>> ParameterValueDisplayStrings;
}

/// \brief 添加静态下拉列表的属性值的宏
/// \param BIPD 参数的枚举名
/// \param StaticValueList 静态下拉列表要显示的属性值
#define ADD_STATIC_VALUE_LIST_PARAMETER_DISPLAY(BIPD, StaticValueList) \
    gcmp::OwnerPtr<IBuiltInParameterDisplayCreator> s_##BIPD = IBuiltInParameterDisplayCreator::AddStacticDropdownListParameterDisplay(PARAMETER_UID(BIPD), StaticValueList); \

/// \brief 添加动态下拉列表的属性值的宏
/// \param BIPD 参数的枚举名
/// \param DynamicValueListType 动态下拉列表要显示的属性值
#define ADD_DYNAMIC_VALUE_LIST_PARAMETER_DISPLAY(BIPD, DynamicValueListType) \
    gcmp::OwnerPtr<IBuiltInParameterDisplayCreator> s_##BIPD = IBuiltInParameterDisplayCreator::AddDynamicDropdownListParameterDisplay(NEW_AS_OWNER_PTR(DynamicValueListType, PARAMETER_UID(BIPD))); \

#define ADD_GCMP_DYNAMIC_VALUE_LIST_PARAMETER_DISPLAY(BIPD, DynamicValueListType) \
    gcmp::OwnerPtr<IBuiltInParameterDisplayCreator> s_##BIPD = IBuiltInParameterDisplayCreator::AddDynamicDropdownListParameterDisplay(gcmp::IParameterValueList::Create##DynamicValueListType (PARAMETER_UID(BIPD))); \

/// \brief 添加带扩展项动态下拉列表的属性值的宏
/// \param BIPD 参数的枚举名
/// \param DynamicValueListType 动态下拉列表要显示的属性值
/// \param ExternalItemDisplayString 扩展项显示字符串
#define ADD_DYNAMIC_VALUE_LIST_WITH_EXTERNALITEM_PARAMETER_DISPLAY(BIPD, DynamicValueListType, ExternalItemDisplayString) \
    gcmp::OwnerPtr<IBuiltInParameterDisplayCreator> s_##BIPD = IBuiltInParameterDisplayCreator::AddDynamicDropdownListWithExternalItemParameterDisplay(NEW_AS_OWNER_PTR(DynamicValueListType, PARAMETER_UID(BIPD)), ExternalItemDisplayString); \

/// \brief GCMP替换动态下拉列表的属性值的宏
/// \param BIPD 参数的枚举名
/// \param DynamicValueListType 动态下拉列表要显示的属性值
#define REPLACE_DYNAMIC_VALUE_LIST_PARAMETER_DISPLAY(BIPD, DynamicValueListType) \
    gcmp::OwnerPtr<IBuiltInParameterDisplayCreator> s_##BIPD = IBuiltInParameterDisplayCreator::ReplaceDynamicDropdownListParameterDisplay(NEW_AS_OWNER_PTR(DynamicValueListType, PARAMETER_UID(BIPD))); \

